<?php

namespace App\Http\Requests\Frontend\V10\Auth;

use App\Rules\MobileCheck;
use App\Rules\PwdCheck;
use Illuminate\Foundation\Http\FormRequest;

class WebRegisterRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'phone_num' => ['bail','required',new MobileCheck,'unique:users'],
            'password' => ['bail','required',new PwdCheck,'confirmed'],
            'source'=>'nullable'
        ];
    }

    public function messages()
    {
        return [
            'phone_num.required' => '手机号码不能为空',
            'phone_num.unique' => '该手机号已存在',
            'password.required' => '密码不能为空',
            'password.confirmed' => '确认密码与密码不一致',
        ];
    }
}
